<!DOCTYPE html>
<html lang="en">
  <head>
    <title>
        Redis-3-事务、持久化 - rulerLwx Blog
      </title>
        <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
      content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-transform" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no,email=no,adress=no">
    
    <meta name="theme-color" content="#000000" />
    
    <meta http-equiv="window-target" content="_top" />
    
    
    <meta name="description" content="事务 概述 事务：在一个队列（QUEUE）中，一次性、顺序性、排他性地执行一系列命令 redis中的事务是一组命令集合，multi &amp;hellip;.. exec。 re" />
    <meta name="generator" content="Hugo 0.73.0 with theme pure" />
    <title>Redis-3-事务、持久化 - rulerLwx Blog</title>
    
    
    <link rel="stylesheet" href="https://rulerLwx.gitee.io/css/style.min.c4bc7071f132c964c2116bca53b392933f377e5ca7b7051ed245187c621a2d3e.css">
    
    <link rel="stylesheet" href="https://cdn.staticfile.org/highlight.js/9.15.10/styles/github.min.css" async>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/tocbot/4.4.2/tocbot.css" async>
    <meta property="og:title" content="Redis-3-事务、持久化" />
<meta property="og:description" content="事务 概述 事务：在一个队列（QUEUE）中，一次性、顺序性、排他性地执行一系列命令 redis中的事务是一组命令集合，multi &hellip;.. exec。 re" />
<meta property="og:type" content="article" />
<meta property="og:url" content="https://rulerLwx.gitee.io/2018/06/redis-3-%E4%BA%8B%E5%8A%A1%E6%8C%81%E4%B9%85%E5%8C%96/" />
<meta property="article:published_time" content="2018-06-05T10:03:47+08:00" />
<meta property="article:modified_time" content="2018-06-05T10:03:47+08:00" />
<meta itemprop="name" content="Redis-3-事务、持久化">
<meta itemprop="description" content="事务 概述 事务：在一个队列（QUEUE）中，一次性、顺序性、排他性地执行一系列命令 redis中的事务是一组命令集合，multi &hellip;.. exec。 re">
<meta itemprop="datePublished" content="2018-06-05T10:03:47&#43;08:00" />
<meta itemprop="dateModified" content="2018-06-05T10:03:47&#43;08:00" />
<meta itemprop="wordCount" content="2261">



<meta itemprop="keywords" content="" /><meta name="twitter:card" content="summary"/>
<meta name="twitter:title" content="Redis-3-事务、持久化"/>
<meta name="twitter:description" content="事务 概述 事务：在一个队列（QUEUE）中，一次性、顺序性、排他性地执行一系列命令 redis中的事务是一组命令集合，multi &hellip;.. exec。 re"/>

    <!--[if lte IE 9]>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/classlist/1.1.20170427/classList.min.js"></script>
      <![endif]-->

    <!--[if lt IE 9]>
        <script src="https://cdn.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script>
        <script src="https://cdn.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js"></script>
      <![endif]-->
  </head>

  
  

  <body class="main-center theme-black" itemscope itemtype="http://schema.org/WebPage"><header class="header" itemscope itemtype="http://schema.org/WPHeader">
    <div class="slimContent">
      <div class="navbar-header">
        <div class="profile-block text-center">
          <a id="avatar" href="https://gitee.com/rulerLwx" target="_blank">
            <img class="img-circle img-rotate" src="https://rulerLwx.gitee.io/avatar.png" width="200" height="200">
          </a>
          <h2 id="name" class="hidden-xs hidden-sm">rulerLwx</h2>
          <h3 id="title" class="hidden-xs hidden-sm hidden-md">thinking...</h3>
          <small id="location" class="text-muted hidden-xs hidden-sm"><i class="icon icon-map-marker"></i>Guangzhou, China</small>
        </div><div class="search" id="search-form-wrap">
    <form class="search-form sidebar-form">
        <div class="input-group">
            <input type="text" class="search-form-input form-control" placeholder="Search" />
            <span class="input-group-btn">
                <button type="submit" class="search-form-submit btn btn-flat" onclick="return false;"><i
                        class="icon icon-search"></i></button>
            </span>
        </div>
        <div class="ins-search">
            <div class="ins-search-mask"></div>
            <div class="ins-search-container">
                <div class="ins-input-wrapper">
                    <input type="text" class="ins-search-input" placeholder="Type something..."
                        x-webkit-speech />
                    <button type="button" class="close ins-close ins-selectable" data-dismiss="modal"
                        aria-label="Close"><span aria-hidden="true">×</span></button>
                </div>
                <div class="ins-section-wrapper">
                    <div class="ins-section-container"></div>
                </div>
            </div>
        </div>
    </form>
</div>
        <button class="navbar-toggle collapsed" type="button" data-toggle="collapse" data-target="#main-navbar" aria-controls="main-navbar" aria-expanded="false">
          <span class="sr-only">Toggle navigation</span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </button>
      </div>
      <nav id="main-navbar" class="collapse navbar-collapse" itemscope itemtype="http://schema.org/SiteNavigationElement" role="navigation">
        <ul class="nav navbar-nav main-nav">
            <li class="menu-item menu-item-home">
                <a href="/">
                    <i class="icon icon-home-fill"></i>
                  <span class="menu-title">Home</span>
                </a>
            </li>
            <li class="menu-item menu-item-archives">
                <a href="/posts/">
                    <i class="icon icon-archives-fill"></i>
                  <span class="menu-title">Archives</span>
                </a>
            </li>
            <li class="menu-item menu-item-categories">
                <a href="/categories/">
                    <i class="icon icon-folder"></i>
                  <span class="menu-title">Categories</span>
                </a>
            </li>
            <li class="menu-item menu-item-tags">
                <a href="/tags/">
                    <i class="icon icon-tags"></i>
                  <span class="menu-title">Tags</span>
                </a>
            </li>
            <li class="menu-item menu-item-about">
                <a href="/about/">
                    <i class="icon icon-cup-fill"></i>
                  <span class="menu-title">About</span>
                </a>
            </li>
        </ul>
      </nav>
    </div>
  </header>

<aside class="sidebar" itemscope itemtype="http://schema.org/WPSideBar">
  <div class="slimContent">
    
      <div class="widget">
    <h3 class="widget-title">Board</h3>
    <div class="widget-body">
        <div id="board">
            <div class="content">enjoy~
            </div>
        </div>
    </div>
</div>

      <div class="widget">
    <h3 class="widget-title"> Categories</h3>
    <div class="widget-body">
        <ul class="category-list">
            <li class="category-list-item"><a href="https://rulerLwx.gitee.io/categories/java-framework/" class="category-list-link">java-framework</a><span class="category-list-count">38</span></li>
            <li class="category-list-item"><a href="https://rulerLwx.gitee.io/categories/java-front-end/" class="category-list-link">java-front-end</a><span class="category-list-count">11</span></li>
            <li class="category-list-item"><a href="https://rulerLwx.gitee.io/categories/java-se/" class="category-list-link">java-se</a><span class="category-list-count">21</span></li>
            <li class="category-list-item"><a href="https://rulerLwx.gitee.io/categories/java-senior/" class="category-list-link">java-senior</a><span class="category-list-count">4</span></li>
            <li class="category-list-item"><a href="https://rulerLwx.gitee.io/categories/linux/" class="category-list-link">linux</a><span class="category-list-count">13</span></li>
            <li class="category-list-item"><a href="https://rulerLwx.gitee.io/categories/tools/" class="category-list-link">tools</a><span class="category-list-count">1</span></li>
            <li class="category-list-item"><a href="https://rulerLwx.gitee.io/categories/%E6%8A%80%E6%9C%AF%E6%9D%82%E7%83%A9/" class="category-list-link">技术杂烩</a><span class="category-list-count">4</span></li>
            <li class="category-list-item"><a href="https://rulerLwx.gitee.io/categories/%E6%95%B0%E6%8D%AE%E5%BA%93/" class="category-list-link">数据库</a><span class="category-list-count">15</span></li>
        </ul>
    </div>
</div>
      <div class="widget">
    <h3 class="widget-title"> Tags</h3>
    <div class="widget-body">
        <ul class="tag-list">
            
            
            <li class="tag-list-item"><a href="https://rulerLwx.gitee.io/tags/jvm/" class="tag-list-link">jvm</a><span
                    class="tag-list-count">1</span></li>
            
            
            <li class="tag-list-item"><a href="https://rulerLwx.gitee.io/tags/%E5%A4%9A%E7%BA%BF%E7%A8%8B/" class="tag-list-link">多线程</a><span
                    class="tag-list-count">2</span></li>
            
            
            <li class="tag-list-item"><a href="https://rulerLwx.gitee.io/tags/%E7%BD%91%E7%BB%9C%E7%BC%96%E7%A8%8B/" class="tag-list-link">网络编程</a><span
                    class="tag-list-count">3</span></li>
            
        </ul>

    </div>
</div>
      
<div class="widget">
    <h3 class="widget-title">Recent Posts</h3>
    <div class="widget-body">
        <ul class="recent-post-list list-unstyled no-thumbnail">
            <li>
                <div class="item-inner">
                    <p class="item-title">
                        <a href="https://rulerLwx.gitee.io/2020/07/%E8%87%AA%E5%B7%B1%E5%8A%A8%E6%89%8B%E4%B8%80%E6%89%B9%E9%87%8F%E7%A7%BB%E5%8A%A8%E9%87%8D%E5%91%BD%E5%90%8D%E6%96%87%E4%BB%B6/" class="title">自己动手（一）——批量移动、重命名文件</a>
                    </p>
                    <p class="item-date">
                        <time datetime="2020-07-27 17:50:02 &#43;0800 CST" itemprop="datePublished">2020-07-27</time>
                    </p>
                </div>
            </li>
            <li>
                <div class="item-inner">
                    <p class="item-title">
                        <a href="https://rulerLwx.gitee.io/2020/07/%E5%85%B3%E4%BA%8Einteger%E7%9A%84-128~127%E7%BC%93%E5%AD%98/" class="title">关于Integer的 -128~127缓存</a>
                    </p>
                    <p class="item-date">
                        <time datetime="2020-07-11 16:56:21 &#43;0800 CST" itemprop="datePublished">2020-07-11</time>
                    </p>
                </div>
            </li>
            <li>
                <div class="item-inner">
                    <p class="item-title">
                        <a href="https://rulerLwx.gitee.io/2020/07/%E8%B7%A8%E5%9F%9F%E9%97%AE%E9%A2%98/" class="title">跨域问题</a>
                    </p>
                    <p class="item-date">
                        <time datetime="2020-07-08 22:41:12 &#43;0800 CST" itemprop="datePublished">2020-07-08</time>
                    </p>
                </div>
            </li>
            <li>
                <div class="item-inner">
                    <p class="item-title">
                        <a href="https://rulerLwx.gitee.io/2020/07/%E4%B8%AA%E4%BA%BA%E5%8D%9A%E5%AE%A2%E6%90%AD%E5%BB%BA/" class="title">个人博客搭建</a>
                    </p>
                    <p class="item-date">
                        <time datetime="2020-07-05 18:58:47 &#43;0800 CST" itemprop="datePublished">2020-07-05</time>
                    </p>
                </div>
            </li>
            <li>
                <div class="item-inner">
                    <p class="item-title">
                        <a href="https://rulerLwx.gitee.io/2020/07/mongodb-1/" class="title">MonggoDB-1</a>
                    </p>
                    <p class="item-date">
                        <time datetime="2020-07-03 18:58:47 &#43;0800 CST" itemprop="datePublished">2020-07-03</time>
                    </p>
                </div>
            </li>
        </ul>
    </div>
</div>
  </div>
</aside>

    
    
<aside class="sidebar sidebar-toc collapse" id="collapseToc" itemscope itemtype="http://schema.org/WPSideBar">
  <div class="slimContent">
    <h4 class="toc-title">Catalogue</h4>
    <nav id="toc" class="js-toc toc">

    </nav>
  </div>
</aside>
<main class="main" role="main"><div class="content">
  <article id="-" class="article article-type-" itemscope
    itemtype="http://schema.org/BlogPosting">
    
    <div class="article-header">
      <h1 itemprop="name">
  <a
    class="article-title"
    href="/2018/06/redis-3-%E4%BA%8B%E5%8A%A1%E6%8C%81%E4%B9%85%E5%8C%96/"
    >Redis-3-事务、持久化</a
  >
</h1>

      <div class="article-meta">
        
<span class="article-date">
  <i class="icon icon-calendar-check"></i>&nbsp;
<a href="https://rulerLwx.gitee.io/2018/06/redis-3-%E4%BA%8B%E5%8A%A1%E6%8C%81%E4%B9%85%E5%8C%96/" class="article-date">
  <time datetime="2018-06-05 10:03:47 &#43;0800 CST" itemprop="datePublished">2018-06-05</time>
</a>
</span>
<span class="article-category">
  <i class="icon icon-folder"></i>&nbsp;
  <a class="article-category-link" href="/categories/%E6%95%B0%E6%8D%AE%E5%BA%93/"> 数据库 </a>
</span>

        <span class="post-comment"><i class="icon icon-comment"></i>&nbsp;<a href="/2018/06/redis-3-%E4%BA%8B%E5%8A%A1%E6%8C%81%E4%B9%85%E5%8C%96/#comments"
            class="article-comment-link">Comments</a></span>
		<span class="post-wordcount hidden-xs" itemprop="wordCount">Word Count: 2261words</span>
		<span class="post-readcount hidden-xs" itemprop="timeRequired">Read Count: 5minutes </span>
      </div>
    </div>
    <div class="article-entry marked-body js-toc-content" itemprop="articleBody">
      <h1 id="事务">事务</h1>
<h2 id="概述">概述</h2>
<ul>
<li>事务：在一个队列（QUEUE）中，一次性、顺序性、排他性地执行一系列命令</li>
<li>redis中的事务是一组命令集合，multi &hellip;.. exec。</li>
<li>redis不支持事务回滚</li>
<li>watch命令：监控一个或多个键，一旦其中有一个键被修改（或删除），之后的事务就不会被执行。</li>
</ul>
<h2 id="常用命令">常用命令</h2>
<table>
<thead>
<tr>
<th>命令</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td>MULTI</td>
<td>标记一个事务块的开始</td>
</tr>
<tr>
<td>DISCARD</td>
<td>取消事务，放弃执行事务块内的<strong>所有命令</strong></td>
</tr>
<tr>
<td>EXEC</td>
<td>执行事务块内的所有命令</td>
</tr>
<tr>
<td>WATCH key [key &hellip;]</td>
<td>监视一个或多个key，如果在事务执行之间这个（或这些）key被其它命令所改动，那么事务将被打断</td>
</tr>
<tr>
<td>UNWATCH</td>
<td>取消 WATCH命令对<strong>所有key</strong>的监视</td>
</tr>
</tbody>
</table>
<h2 id="示例">示例</h2>
<p>1）正常执行<code>multi ..... exec</code></p>
<pre><code>127.0.0.1:6379&gt; MULTI
OK
127.0.0.1:6379&gt; set k1 v1
QUEUED
127.0.0.1:6379&gt; set k2 v2
QUEUED
127.0.0.1:6379&gt; set k3 v3
QUEUED
127.0.0.1:6379&gt; EXEC
1) OK
2) OK
3) OK
127.0.0.1:6379&gt; 
</code></pre>
<p>2）放弃事务</p>
<pre><code>127.0.0.1:6379&gt; MULTI
OK
127.0.0.1:6379&gt; set k1 11
QUEUED
127.0.0.1:6379&gt; set k2 22
QUEUED
127.0.0.1:6379&gt; DISCARD
OK
127.0.0.1:6379&gt; 
</code></pre>
<p>3）全体连坐</p>
<p>如果在加入队列时，有一条语句执行错误，则全部事务将失效，即：要么全成功，要么全部放弃。</p>
<pre><code>127.0.0.1:6379&gt; MULTI
OK
127.0.0.1:6379&gt; set k1 aa
QUEUED
127.0.0.1:6379&gt; set k2 bb
QUEUED
127.0.0.1:6379&gt; setget k3 cc
(error) ERR unknown command `setget`, with args beginning with: `k3`, `cc`, 
127.0.0.1:6379&gt; set k4 dd
QUEUED
127.0.0.1:6379&gt; EXEC
(error) EXECABORT Transaction discarded because of previous errors.
127.0.0.1:6379&gt; 
</code></pre>
<p>4）冤头债主</p>
<p>EXEC 时，INCR k1 产生错误，但不影响后面的执行。跟上面的“全体连坐”不同，“全体连坐”是在加入 QUEUE 时就错误了。</p>
<p>这里可以看到，Redis不支持事务回滚。</p>
<pre><code>127.0.0.1:6379&gt; MULTI
OK
127.0.0.1:6379&gt; INCR k1
QUEUED
127.0.0.1:6379&gt; set k2 gg
QUEUED
127.0.0.1:6379&gt; set k3 hh
QUEUED
127.0.0.1:6379&gt; EXEC
1) (error) ERR value is not an integer or out of range
2) OK
3) OK
127.0.0.1:6379&gt; 
</code></pre>
<p>5）WATCH 监控</p>
<p>先监控，再开启事务</p>
<pre><code>127.0.0.1:6379&gt; set balance 100
OK
127.0.0.1:6379&gt; set debt 0
OK


127.0.0.1:6379&gt; WATCH balance
127.0.0.1:6379&gt; MULTI
OK
127.0.0.1:6379&gt; DECRBY balance 20
QUEUED
127.0.0.1:6379&gt; INCRBY debt 20
QUEUED
127.0.0.1:6379&gt; EXEC
1) (integer) 80
2) (integer) 20
127.0.0.1:6379&gt; 
</code></pre>
<p>总结：修改重要数据字段时，先<code>WATCH</code>该字段，再执行<code>MULTI...EXEC</code>，事务执行成功后，<code>WATCH</code> 才失效，此时不需要再执行<code>UNWATCH</code>命令。</p>
<h2 id="悲观锁乐观锁">悲观锁、乐观锁</h2>
<ul>
<li>悲观锁，以数据表为例</li>
<li>乐观锁，<code>WATCH</code>命令就是乐观锁，可以理解为用版本控制</li>
<li>CAS，</li>
</ul>
<p><img src="https://gitee.com/leafsing/pic/raw/master/img/20200709091442.png" alt=""></p>
<p><img src="https://gitee.com/leafsing/pic/raw/master/img/20200709091525.png" alt=""></p>
<h1 id="持久化">持久化</h1>
<h2 id="rdbredis-database方式">RDB（Redis DataBase）方式</h2>
<p>当符合一定条件时Redis会自动将内存中的所有数据生成一份副本并存储在硬盘上，这个过程即为“快照”（snapshotting）</p>
<p>RDB方式默认是开启的，文件的<strong>存储位置、名称</strong>在redis.conf中配置。</p>
<p>Redis执行快照的时机：</p>
<ul>
<li>快照规则配置</li>
<li>手动执行save/bgsave 命令</li>
<li>手动执行flushall 命令</li>
<li>执行复制（replication）时。</li>
</ul>
<p>1、快照规则配置</p>
<pre><code>语法：save &lt;seconds&gt; &lt;changes&gt;

save 900 1      # save 时间（秒） 改动的键数，可以配置多个条件，条件之间是‘或’关系
save 300 10
save 60 10000

官方解释：
#   In the example below the behaviour will be to save:
#   after 900 sec (15 min) if at least 1 key changed
#   after 300 sec (5 min) if at least 10 keys changed
#   after 60 sec if at least 10000 keys changed
</code></pre>
<p>2、<code>sava/bgsave</code>命令</p>
<pre><code>此处是手动进行快照（如服务器关闭前）

save，同步快照，会阻塞请求，生产环境不建议使用
bgsave，异步快照
</code></pre>
<p>3、<code>flushall/shutdown</code>命令</p>
<pre><code>flushall命令会清除数据库中的所有数据（0~15的数据库），此时会触发快照条件（快照规则不为空）

注意：此时内存中的数据全部清空了，然后触发快照生成了新的dump.db文件，此时的dump.db是空的，没有任何数据。——20190914
</code></pre>
<p>4、执行复制（master/slave）时</p>
<pre><code>执行复制时都会生成快照文件（不管快照规则是否为空，有没有手动执行快照）
</code></pre>
<p>总结：</p>
<p><img src="https://gitee.com/leafsing/pic/raw/master/img/20200709091545.png" alt=""></p>
<h2 id="aofappend-only-file方式">AOF（Append Only File）方式</h2>
<p>aof方式，可以防止数据丢失：redis的每一条<strong>写命令</strong>都会追加到硬盘中，但读命令不记录；只允许追加文件，不可以改写文件。</p>
<p>注意：<code>FLUSHALL</code>命令也会记录在<code>appendonly.aof</code>文件中。</p>
<p>aof方式以纯文本形式记录redis执行的命令。</p>
<p>aof文件保存位置和rdb文件位置相同，默认文件名是appendonly.aof，可以通过以下参数配置：</p>
<pre><code>appendonly yes      # 启用aof方式
dir ./              # 文件位置
appendfilename appendfilename   # 文件名称
</code></pre>
<p>命令执行得越多，aof的文件越大，且有冗余的命令，如何优化？—— 配置aof重写</p>
<pre><code>auto-aof-rewrite-percentage 100    # 当前aof文件大小超过上次重写时的aof文件大小的百分之几时时会再次进行重写
auto-aof-rewrite-min-size 64mb  重写的最小aof文件大小
</code></pre>
<p>重写aof的目的是<strong>去除冗余的命令</strong></p>
<p>redis允许同时开启aof和rdb</p>
<p>常用配置（redis.conf）：</p>
<ul>
<li><code>appendonly yes</code> ：启用aof方式</li>
<li><code>dir ./</code> ：文件位置</li>
<li><code>appendfilename appendfilename</code>：文件名称</li>
<li><code>appendfsync always/everysec/no</code>：默认用everysec，也是推荐配置</li>
<li><code>no-appendfsync-on-rewrite no</code>：重写时是否可以运用appendfsync，用默认的no即可，保证数据安全性</li>
<li><code>auto-aof-rewrite-percentage 100</code>：重写基准值，当前aof文件大小超过上次重写时的aof文件大小的百分之几时时会再次进行重写</li>
<li><code>auto-aof-rewrite-min-size 64mb</code>：重写基准值，重写的最小aof文件大小</li>
</ul>
<p>总结：</p>
<p><img src="https://gitee.com/leafsing/pic/raw/master/img/20200709091609.png" alt=""></p>
<p><img src="https://gitee.com/leafsing/pic/raw/master/img/20200709091629.png" alt=""></p>
<h2 id="如何恢复rdb或aof数据到内存">如何恢复rdb或aof数据到内存？</h2>
<p>将<code>dump.rdb</code>或<code>appendonly.aof</code>放到安装目录，重新启动redis服务即可。客户端可以使用<code>config get dir</code>获取安装目录。——20190914</p>
<p>问：redis允许同时开启aof和rdb，数据恢复时，以谁为主？优先执行谁？</p>
<p>答：如果开启了aof方式，则加载的是<code>appendonly.aof</code>；如果没有开启aof，则加载<code>dump.rdb</code>。</p>
<hr>
<p>检查、修复aof文件：<code>./redis-check-aof --fix appendonly</code></p>
<hr>
<p>参考：</p>
<ul>
<li>redis执行了flushdb或者flushall之后的“后悔药”操作：https://blog.csdn.net/qq_25551295/article/details/48103245#commentBox</li>
<li>Redis 禁用FLUSHALL FLUSHDB KEYS 命令：https://blog.csdn.net/u011250882/article/details/48580003</li>
</ul>
<h2 id="同步硬盘数据">同步硬盘数据</h2>
<pre><code># appendfsync always
appendfsync everysec    # 每秒同步一次到硬盘
# appendfsync no        # 操作系统默认每30秒将硬盘缓存的数据写入硬盘
</code></pre>

    </div>
    <div class="article-footer">
<blockquote class="mt-2x">
  <ul class="post-copyright list-unstyled">
    <li class="post-copyright-link hidden-xs">
      <strong>Permalink: </strong>
      <a href="https://rulerLwx.gitee.io/2018/06/redis-3-%E4%BA%8B%E5%8A%A1%E6%8C%81%E4%B9%85%E5%8C%96/" title="Redis-3-事务、持久化" target="_blank" rel="external">https://rulerLwx.gitee.io/2018/06/redis-3-%E4%BA%8B%E5%8A%A1%E6%8C%81%E4%B9%85%E5%8C%96/</a>
    </li>
    <li class="post-copyright-license">
      <strong>License：</strong><a href="http://creativecommons.org/licenses/by/4.0/deed.zh" target="_blank" rel="external">CC BY 4.0 CN</a>
    </li>
  </ul>
</blockquote>

<div class="panel panel-default panel-badger">
  <div class="panel-body">
    <figure class="media">
      <div class="media-left">
        <a href="https://gitee.com/rulerLwx" target="_blank" class="img-burn thumb-sm visible-lg">
          <img src="https://rulerLwx.gitee.io/avatar.png" class="img-rounded w-full" alt="">
        </a>
      </div>
      <div class="media-body">
        <h3 class="media-heading"><a href="https://gitee.com/rulerLwx" target="_blank"><span class="text-dark">rulerLwx</span><small class="ml-1x">thinking...</small></a></h3>
        <div>Good Good Study, Day Day Up~</div>
      </div>
    </figure>
  </div>
</div>
    </div>
  </article>
<section id="comments">
    <div id="vcomments"></div>
</section>

</div><nav class="bar bar-footer clearfix" data-stick-bottom>
    <div class="bar-inner">
        <ul class="pager pull-left">
            <li class="prev">
                <a href="https://rulerLwx.gitee.io/2018/06/redis-2-%E8%BF%87%E6%9C%9F%E5%AE%89%E5%85%A8%E6%8E%92%E5%BA%8F%E6%B6%88%E6%81%AFqa/" title="Redis-2-过期、安全、排序、消息、QA"><i
                        class="icon icon-angle-left"
                        aria-hidden="true"></i><span>&nbsp;&nbsp;Older</span></a>
            </li>
            <li class="next">
                <a href="https://rulerLwx.gitee.io/2018/06/redis-4-%E4%B8%BB%E4%BB%8E%E5%A4%8D%E5%88%B6%E5%93%A8%E5%85%B5%E9%9B%86%E7%BE%A4/"
                    title="Redis-4-主从复制、哨兵、集群"><span>Newer&nbsp;&nbsp;</span><i
                        class="icon icon-angle-right" aria-hidden="true"></i></a>
            </li>
            
            <li class="toggle-toc">
                <a class="toggle-btn collapsed" data-toggle="collapse" href="#collapseToc" aria-expanded="false"
                    title="Catalogue" role="button">
                    <span>[&nbsp;</span><span>Catalogue</span>
                    <i class="text-collapsed icon icon-anchor"></i>
                    <i class="text-in icon icon-close"></i>
                    <span>]</span>
                </a>
            </li>
        </ul>
        <div class="bar-right">
            <div class="share-component" data-sites="weibo,qq,wechat"
                data-mobile-sites="weibo,qq,qzone"></div>
        </div>
    </div>
</nav>

</main><footer class="footer" itemscope itemtype="http://schema.org/WPFooter">
<ul class="social-links">
    <li><a href="https://gitee.com/rulerLwx" target="_blank" title="gitee" data-toggle=tooltip data-placement=top >
            <i class="icon icon-gitee"></i></a></li>
    <li><a href="https://github.com/wolf-lea" target="_blank" title="github" data-toggle=tooltip data-placement=top >
            <i class="icon icon-github"></i></a></li>
</ul>
  <div class="copyright">
    &copy;2017  -
    2020
    <div class="publishby">
        Theme by <a href="https://github.com/xiaoheiAh" target="_blank"> xiaoheiAh </a>base on<a href="https://github.com/xiaoheiAh/hugo-theme-pure" target="_blank"> pure</a>.
    </div>
  </div>
</footer>

<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js?config=TeX-MML-AM_SVG"></script>
<script type="text/x-mathjax-config">
    MathJax.Hub.Config({
            showMathMenu: false, //disables context menu
            tex2jax: {
            inlineMath: [ ['$','$'], ['\\(','\\)'] ]
           }
    });
</script>


<script src="https://cdn.jsdelivr.net/npm/jquery@3.4.1/dist/jquery.min.js"></script>
<script>
    window.jQuery || document.write('<script src="js/jquery.min.js"><\/script>')
</script>
<script type="text/javascript" src="https://cdn.staticfile.org/highlight.js/9.15.10/highlight.min.js"></script>
<script type="text/javascript" src="https://cdn.staticfile.org/highlight.js/9.15.10/languages/python.min.js" defer></script>
<script type="text/javascript" src="https://cdn.staticfile.org/highlight.js/9.15.10/languages/javascript.min.js" defer></script><script>
    hljs.configure({
        tabReplace: '    ', 
        classPrefix: ''     
        
    })
    hljs.initHighlightingOnLoad();
</script>
<script src="https://rulerLwx.gitee.io/js/application.min.bdeb64b910570b6c41badc6a05b7afb0c8ad9efd8525de3c7257d59e786326a3.js"></script>
<script src="https://rulerLwx.gitee.io/js/plugin.min.51ff8c7317566f82259170fa36e09c4493adc9b9378b427a01ad3f017ebac7dd.js"></script>

<script>
    (function (window) {
        var INSIGHT_CONFIG = {
            TRANSLATION: {
                POSTS: 'Posts',
                PAGES: 'Pages',
                CATEGORIES: 'Categories',
                TAGS: 'Tags',
                UNTITLED: '(Untitled)',
            },
            ROOT_URL: 'https:\/\/rulerLwx.gitee.io',
            CONTENT_URL: 'https:\/\/rulerLwx.gitee.io\/searchindex.json ',
        };
        window.INSIGHT_CONFIG = INSIGHT_CONFIG;
    })(window);
</script>
<script type="text/javascript" src="https://rulerLwx.gitee.io/js/insight.min.a343cd9a5a7698336b28ef3a7c16a3a1b1d2d5fb17dc8ed04022bbe08cc5459073a15bdafa3a8a58cdd56080784bdd69fa70b1ae8597565c799c57ed00f0e120.js" defer></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tocbot/4.4.2/tocbot.min.js"></script>
<script>
    tocbot.init({
        
        tocSelector: '.js-toc',
        
        contentSelector: '.js-toc-content',
        
        headingSelector: 'h1, h2, h3',
        
        hasInnerContainers: true,
    });
</script>

<script src="https://cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/valine"></script>
<script type="text/javascript">
    var GUEST = ['nick', 'mail', 'link'];
    var meta = 'nick,mail';
    meta = meta.split(',').filter(function (item) {
        return GUEST.indexOf(item) > -1;
    });
    new Valine({
        el: '#vcomments',
        verify: null ,
        notify: null ,
        appId: 'IyAB0PSPRazTPDxitO1ddQ7O-gzGzoHsz',
        appKey: '5rBJTq4KidYF33eXwvRVhtEH',
        placeholder: 'enjoy~',
        avatar: 'mm',
        meta: meta,
        pageSize: '10' || 10,
        visitor: false 
});
</script>

  </body>
</html>
